package cn.wanho.controller.feign;

import cn.wanho.CmsUserThreadLocal.UserThreadLocal;
import cn.wanho.dto.CmsUser;
import cn.wanho.feign.FeignService;
import cn.wanho.rvo.ResultVO;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/exam")
public class FeignController {
    @Resource
    private FeignService feignService;

    @GetMapping("/testCheck")
    public String testCheck(){
        CmsUser cmsUser = UserThreadLocal.get();
        return feignService.feign1(cmsUser.getId());
    }

    @GetMapping("/testing")
    public String testing(@RequestParam(value = "paperId") Integer paperId){
        CmsUser cmsUser = UserThreadLocal.get();
        return feignService.feign2(paperId, cmsUser.getId());
    }

    @PostMapping("/saveAnswer")
    public String saveExam(@RequestParam(value = "questionId") String questionId, @RequestParam(value = "answerContent") String answerContent, @RequestParam(value = "paperId") String paperId){
        Integer id = UserThreadLocal.get().getId();
        return feignService.feign3(questionId,answerContent,paperId,id);
    }

    @PostMapping("/commit")
    public String commit(@RequestParam(value = "paperId") String paperId){
        Integer userId = UserThreadLocal.get().getId();
        //String userId = "1";
        //return examService.commit(paperId,userId);
        return feignService.fegin4(userId,paperId);
    }
    @GetMapping("/showpaper")
    public String showPaper(@RequestParam(value = "paperId") Integer paperId,@RequestParam(value = "sort")Integer sort){
        Integer studentId = UserThreadLocal.get().getId();
        return feignService.fegin5(paperId,sort,studentId);
    }
}
